class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.string :user_name          ,:limit => 10
      t.string :employee_no        ,:limit => 15    #员工工号
      t.string :password           ,:limit => 15
      t.string :address            ,:limit => 80
      t.string :login_id           ,:limit => 15
      t.string :login_ip           ,:limit => 40
      t.string :limited_ip         ,:limit => 40
      t.string :user_type          ,:limit => 15 ,:default=>''
      t.string :eterm_name         ,:limit => 15 ,:default=>''  #连接放大器或中航信的用户名密码
      t.string :eterm_pswd         ,:limit => 15 ,:default=>''
      t.integer :department_id     ,:default => 1 ,:limit => 2
      t.integer :latest_chat_id    ,:default => 0
      t.integer :is_online         ,:default => 1 ,:limit => 1
      t.integer :is_locked ,:limit => 1 ,:default => 0 #是否管理会要锁定 1为True 0为False
      t.integer :lock_version      , :default => 0 #乐观锁
      t.timestamps
    end
    User.create(:user_name => '未指定人员',:login_id=>'000',:employee_no =>'000',:password =>'000',:eterm_name=>'tao22070',:eterm_pswd=>'tao22070',:department_id =>'1',:is_online=>'1',:user_type=>'admin',:is_locked => 1)
    User.create(:user_name => 'Mike',:login_id=>'666',:employee_no =>'001',:password =>'666',:eterm_name=>'tao22071',:eterm_pswd=>'tao22071',:department_id =>'1',:is_online=>'1',:user_type=>'admin')
    User.create(:user_name => 'Jerry',:login_id=>'777',:employee_no =>'002',:password =>'777',:eterm_name=>'tao22072',:eterm_pswd=>'tao22072',:department_id =>'1',:is_online=>'1',:user_type=>'admin')
    User.create(:user_name => 'Peter',:login_id=>'555',:employee_no =>'003',:password =>'555',:eterm_name=>'tao22073',:eterm_pswd=>'tao22073',:department_id =>'1',:is_online=>'1')
    User.create(:user_name => 'John',:login_id=>'444',:employee_no =>'004',:password =>'444',:eterm_name=>'tao22074',:eterm_pswd=>'tao22074',:department_id =>'2',:is_online=>'1',:user_type=>'送票员')
    User.create(:user_name => '送票员1',:login_id=>'333',:employee_no =>'005',:password =>'333',:eterm_name=>'tao22075',:eterm_pswd=>'tao22075',:department_id =>'3',:is_online=>'1',:user_type=>'送票员')
    User.create(:user_name => 'admin',:login_id=>'888',:employee_no =>'006',:password =>'888',:eterm_name=>'tao22076',:eterm_pswd=>'tao22076',:department_id =>'1',:is_online=>'1',:user_type=>'super_admin')
  end
  
  def self.down
    drop_table :users
  end
end
